/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.proxy;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.edi.client.param.EdiClientRequest;
import com.edi.client.plugin.PluginResult;
import com.edi.exceptions.EdiParamException;

public class EdiParamProxy {
	private static final Log log = LogFactory.getLog(EdiParamProxy.class);

	private String ediPara;

	private EdiClientRequest ediClientRequest;

	private PluginResult result;

	public EdiParamProxy(String ediPara) throws EdiParamException {
		this.ediPara = ediPara;
		init();
	}

	/**
	 * 
	 * @throws EdiParamException
	 */
	private void init() throws EdiParamException {
		try {
			ediClientRequest = new EdiClientRequest(this.ediPara);
		} catch (Exception e) {
			e.printStackTrace();
			throw new EdiParamException("Parse edi client request is wrong ! ",
					e);
		}
	}

	/**
	 * 处理客户端的请求
	 * 
	 */
	public void process() throws EdiParamException {
		ediClientRequest.process();
	}

	/**
	 * 返回客户端所需要的信息
	 * 
	 * @return
	 */
	public String getAnswerXml() throws EdiParamException {
		return ediClientRequest.getAnswerXml();
	}

	public boolean isFileRequest() throws EdiParamException {
		return ediClientRequest.isFileRequest();
	}

	public Object getResult() {
		return ediClientRequest.getSpoReuslt();
	}

}
